operation-binding companion extension and TS prototype#1932
operation-binding companion extension and TS prototype#1932ayushozha wants to merge 6 commits intox402-foundation:mainfrom
Conversation
|
This draft now includes a concrete TypeScript prototype in Included in the prototype:
Validation run locally:
If this is the right first-step shape, I can keep iterating from here rather than expanding the scope further. |
|
Direction looks right to me — keeping it as a companion extension so receipt format churn doesn't cascade is the sane call. One question on scope: the v1 receipt is resource-server-signed, which works for any scheme. But some schemes can carry the binding natively — e.g. BOLT11 Not asking you to solve it here, just trying to understand whether the v1 shape would let that plug in later or whether it'd need its own extension. |
|
Ran the TS prototype on this branch against The Concrete: body
Same story with Test vectorsWhile both impls were running, pinned 8 vectors against the two example bindings (
Would be worth pinning a subset of these in the spec as a Test Vectors appendix — independent SDK authors get a bit-for-bit target to verify against, which is the cheapest insurance against drift. One more number-related thing
Can send a small PR against this branch with the escape fix plus regression tests for |
|
Addressed the RFC 8785 escaping bug in the shared canonicalizer. What changed:
Ran locally:
This is on the branch now in |
|
The operation-binding extension fills the gap between payment and execution cleanly. The operationDigest approach — RFC 8785 canonicalization, SHA-256 digest, deterministic binding — is exactly the right primitive for that layer. One composition point worth flagging for the spec: the operation-binding receipt answers "was this exact validated operation paid for?" but doesn't address what comes after execution — whether the delivery matched the specification. SAR (Settlement Attestation Receipt, #1195) is designed to fill that slot. It operates post-execution and produces a signed delivery proof using the same verification profile: RFC 8785 canonicalization, SHA-256 digest derivation, Ed25519 signatures, kid-indexed key discovery. The signed core is intentionally narrow so it composes with operation-binding without coupling envelope semantics. The full stack would then be: operationDigest (payment bound to exact operation) → execution → SAR (delivery bound to spec) → reputation signal On the RFC 8785 escaping issue Bortlesboat identified — SAR's canonicalization implementation uses correct short-form escapes for \b \f \n \r \t per §3.2.2.2. The sar-sdk fixture suite includes vectors covering the \n and \t cases (V4 and V5 in Bortlesboat's table). Happy to share those vectors if useful for cross-validation. For the shared canonicalization test vector appendix Bortlesboat proposed — aligning SAR fixtures with the operation-binding vector set would give independent implementers a single target to validate both layers against. |
|
@phdargen looping you in for a maintainer read here. @Bortlesboat's feedback makes me think the companion-extension / first-slice approach is directionally right. Since then this branch has also incorporated the RFC 8785 escaping fix, pinned digest regression vectors, and a small HTTP-flow integration test around operation-binding. Is this aligned with where you want operation-binding to head? If yes, would you want this merged as the initial prototype and iterate follow-up spec/runtime work in separate PRs, or would you prefer it narrowed or split further before merge? |
|
@Bortlesboat since you’ve already been the main technical reviewer on this thread: with the RFC 8785 escape fix, pinned digest vectors, and the small HTTP-flow integration coverage now on the branch, does this look like the right initial prototype to merge and iterate on in follow-up PRs, or would you prefer it narrowed or split further first? |
|
Escape fix looks correct, vectors match. This is the right shape to merge and iterate. Only thing I'd track for a follow-up is a Test Vectors appendix in the spec doc itself the TS test suite has them pinned, but SDK authors in other languages will want a bit-for-bit target without having to dig through the TypeScript. Merge it. |
|
Thanks, that’s very helpful, @Bortlesboat. I’ll keep the Test Vectors appendix as follow-up work so this PR stays narrow. At this point the branch looks stable and the remaining GitHub blocker appears to be a formal approving review from someone with merge rights. |
|
@phdargen @CarsonRoscoe could you take a look at this when you have a moment? Given @Bortlesboat's review that this is the right first shape to merge and iterate on, I’d mainly like to confirm whether this is aligned with the direction you want operation-binding to head. If yes, I’m happy to keep the Test Vectors appendix and any broader follow-up work in separate PRs. |
Summary
This draft PR still starts with the first narrow slice from #1921: a standalone
operation-bindingcompanion extension. It now also includes a TypeScript prototype in@x402/extensionsso reviewers can react to both the proposed spec surface and a concrete SDK shape.The goal is still to keep this first step narrow:
operationDigestoffer-and-receiptWhat This PR Includes
Spec draft
specs/extensions/operation-binding.mdoperationDigestinputspayment-identifieroffer-and-receiptand Facilitator-side attestation to complement offer-receipt — coordination proposal #1802TypeScript prototype
@x402/extensions/operation-bindingentrypoint402 Payment RequiredWhat This PR Does Not Yet Do
For the prototype, I kept the code in
@x402/extensionsrather than wiring it directly into core server settlement hooks, because the current hook surface does not yet expose enough validated operation context to do that cleanly.Validation
Ran locally:
pnpm --dir typescript --filter @x402/extensions test -- operation-binding.test.tspnpm --dir typescript --filter @x402/extensions buildReview Intent
This PR is meant to answer two questions:
If this is directionally right, I can follow up by either:
Refs #1921